/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.sena.zocode.modelo.DAO;

import co.edu.sena.zocode.modelo.VO.CategoriaVO;
import co.edu.sena.zocode.modelo.VO.ProductoVO;
import co.edu.sena.zocode.modelo.conexion.Conexion;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 *
 * @author SANDRA
 */
public class CategoriaDAO extends Conexion {

    public ArrayList<CategoriaVO> listarCategorias() {
        ArrayList<CategoriaVO> lista = new ArrayList<>();
        try {
            conectar();
            PreparedStatement sent = cnn.prepareStatement(" select * from categorias");
            ResultSet resul = sent.executeQuery();
            while (resul.next()) {
                int idcateg = resul.getInt("idcategoria");
                String nombre_prod = resul.getString("nombreCategoria");
                
                CategoriaVO data = new CategoriaVO();
                  data.setIdCategoria(idcateg);
                  data.setNombreCategoria(nombre_prod);
                lista.add(data);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            desconectar();
        }
        return lista;

    }

}
